﻿using System;
using System.Globalization;
using Loki.Model;
using Luna.Data.Crm;
using Luna.Model.Common;

namespace Luna.Model.Crm
{
    internal class Entity : LunaReferenceElement<IEntityData>, IEntity, IAtomicEntity<Guid, IEntityData>
    {
        public Entity()
        {
        }

        public Entity(IEntityData data)
            : base(data)
        {
        }

        public Entity(Entity clone)
            : base(clone)
        {
            Data.Address = clone.Address;
            Data.City = clone.City;
            Data.Company = clone.Company;
            Data.Country = clone.Country;
            Data.Description = clone.Description;
            Data.Fax = clone.Fax;
            Data.Mail = clone.Mail;
            Data.Manager = clone.Manager;
            Data.Mobile = clone.Mobile;
            Data.Name = clone.Name;
            Data.NoMail = clone.NoMail;
            Data.Phone = clone.Phone;
            Data.Sector = clone.Sector;
            Data.Skype = clone.Skype;
            Data.Source = clone.Source;
            Data.Status = clone.Status;
            Data.Surname = clone.Surname;
            Data.Title = clone.Title;
            Data.Twitter = clone.Twitter;
            Data.Url = clone.Url;
            Data.ZipCode = clone.ZipCode;
        }

        public string FullName
        {
            get
            {
                return string.Format(CultureInfo.CurrentCulture, FullNameFormat, Title, Surname, Name);
            }
        }

        private const string FullNameFormat = "{0} {1} {2}";

        public string Manager
        {
            get { return Data.Manager; }
        }

        public string Surname
        {
            get { return Data.Surname; }
        }

        public string Name
        {
            get { return Data.Name; }
        }

        public string Company
        {
            get { return Data.Company; }
        }

        public string Title
        {
            get { return Data.Title; }
        }

        public string Phone
        {
            get { return Data.Phone; }
        }

        public string Mobile
        {
            get { return Data.Mobile; }
        }

        public string Source
        {
            get { return Data.Source; }
        }

        public string Url
        {
            get { return Data.Url; }
        }

        public string Mail
        {
            get { return Data.Mail; }
        }

        public string Fax
        {
            get { return Data.Fax; }
        }

        public string Status
        {
            get { return Data.Status; }
        }

        public string Skype
        {
            get { return Data.Skype; }
        }

        public string Twitter
        {
            get { return Data.Twitter; }
        }

        public string Sector
        {
            get { return Data.Sector; }
        }

        public bool NoMail
        {
            get { return Data.NoMail; }
        }

        public string Address
        {
            get { return Data.Address; }
        }

        public string ZipCode
        {
            get { return Data.ZipCode; }
        }

        public string City
        {
            get { return Data.City; }
        }

        public string Country
        {
            get { return Data.Country; }
        }

        public string Description
        {
            get { return Data.Description; }
        }

        public IEditableEntity EditableCopy
        {
            get { return new EditableEntity(this); }
        }
    }
}